home *** CD-ROM | disk | FTP | other *** search
- #ifndef FWEXCRUN_H
- #define FWEXCRUN_H
-
- //========================================================================================
- //
- // File: FWExcRun.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FW_NATIVE_EXCEPTIONS
-
- #ifndef FWEXCEPT_H
- #include "FWExcept.h"
- #endif
-
- #ifndef FWDELSTA_H
- #include "FWDelSta.h"
- #endif
-
- #ifndef FWEXCTAS_H
- #include "FWExcTas.h"
- #endif
-
- #ifdef FW_DEBUG
- #include <stdio.h>
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- class FW_CLASS_ATTR FW_CPrivTryBlockContext;
- class FW_CLASS_ATTR _FW_CAutoDestructObject;
-
- #ifdef FW_USE_NEW_HELPER
- class FW_CLASS_ATTR FW_CPrivNewHelper;
- #endif
-
- //========================================================================================
- // Functions for "unexpected" and "terminate"
- //
- // See ARM, Section 15.6
- //========================================================================================
-
- #ifndef __BORLANDC__
- extern void terminate();
- extern void unexpected();
-
- extern PFV set_terminate(PFV);
- extern PFV set_unexpected(PFV);
- #endif
-
- //========================================================================================
- // CLASS FW_CPrivExceptionRuntime
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CPrivExceptionRuntime
- {
- public:
- enum
- {
- kDefaultExceptionBufferSize = 128
- // Exception buffer size in bytes.
- // This limits size of largest exception object that may be thrown
- };
-
- static void Initialize(FW_SPrivExceptionGlobals& globals);
- static void Terminate();
-
- static void Throw(const _FW_XException & thrownException);
- static void ThrowSame();
- static void ThrowConstructor(_FW_XException & thrownException);
- static void ThrowSameConstructor();
- static void CaughtException(FW_SPrivExceptionGlobals& globals, _FW_XException * caughtException);
- static void CaughtEverythingException(FW_SPrivExceptionGlobals& globals);
- static void CaughtNoInstanceException(FW_SPrivExceptionGlobals& globals);
- static void CaughtReferenceException(FW_SPrivExceptionGlobals& globals);
- static void KeepThrowing(FW_SPrivExceptionGlobals& globals);
- static void CatchCleanup(FW_SPrivExceptionGlobals& globals);
- static void ResetExceptionBufferSize(size_t newSize);
- static PFV SetTerminate(PFV);
- static PFV SetUnexpected(PFV);
-
- static void EndConstructor(_FW_CAutoDestructObject *object, size_t size);
-
- #ifdef FW_DEBUG
- static FW_ClassInfoPtr SetBreakOnThrow(FW_ClassInfoPtr breakExceptionKind = NULL);
- static FW_ClassInfoPtr GetBreakOnThrow();
- #endif
-
- private:
- static void DeleteObjectsInContextAndJump(FW_SPrivExceptionGlobals& globals, FW_CPrivTryBlockContext * FWTryBlo);
- static void PrimitiveThrow(const _FW_XException & thrownException);
- static void PrimitiveThrowSame();
-
- };
-
- //========================================================================================
- // CLASS FW_CPrivExceptionRuntime INLINE Functions
- //========================================================================================
-
- #ifdef FW_DEBUG
- inline FW_ClassInfoPtr FW_CPrivExceptionRuntime::SetBreakOnThrow(FW_ClassInfoPtr breakExceptionKind)
- {
- FW_ClassInfoPtr previous = FW_CExceptionTaskGlobals::GetExceptionGlobals().gBreakExceptionKind;
- FW_CExceptionTaskGlobals::GetExceptionGlobals().gBreakExceptionKind = breakExceptionKind;
- return previous;
- }
- #endif
-
- #ifdef FW_DEBUG
- inline FW_ClassInfoPtr FW_CPrivExceptionRuntime::GetBreakOnThrow()
- {
- return FW_CExceptionTaskGlobals::GetExceptionGlobals().gBreakExceptionKind;
- }
- #endif
-
- //========================================================================================
- // CLASS FW_CPrivExceptionRuntime INLINE Functions (Platform-independent Versions)
- //========================================================================================
-
- inline void FW_CPrivExceptionRuntime::CatchCleanup(FW_SPrivExceptionGlobals& globals)
- {
- globals.gCaughtException = NULL;
- globals.gThrownException = NULL;
- }
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif // FW_NATIVE_EXCEPTIONS
-
- #endif
-